import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../views/home')
  },
  // 产品展示
  {
    path: '/product',
    name: 'Product',
    component: () => import('../views/product')
  },
  // 关于公司
  {
    path: '/inRegard',
    name: 'InRegard',
    component: () => import('../views/inRegard')
  },
  // 业绩
  {
    path: '/performance',
    name: 'Performance',
    component: () => import('../views/performance')
  },
  // 联系我们
  {
    path: '/contactUs',
    name: 'ContactUs',
    component: () => import('../views/contactUs')
  }
]

const router = new VueRouter({
  routes
})
// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
let routerReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch(err => err)
}


export default router
